import os
import tkinter as tk
from tkinter import filedialog, messagebox
from tkinter.scrolledtext import ScrolledText
from functions import show_functions  # 你的功能模块
from settings import show_settings  # 你的设置模块
from help import show_help  # 你的帮助模块
from tools import log_operation

# 创建主窗口
window = tk.Tk()
window.title("opentelnet")
window.geometry("800x600")  # 修改窗口大小为800x600

# 上部分
upper_frame = tk.Frame(window, height=500)
upper_frame.pack(side="top", fill="both", expand=False)
upper_frame.pack_propagate(False)  # 禁用自动调整大小

# 下部分
lower_frame = tk.Frame(window, height=100)
lower_frame.pack(side="bottom", fill="both", expand=False)

# 左边部分
left_frame = tk.Frame(upper_frame, width=100)
left_frame.pack(side="left", fill="y")

# 右边部分
right_frame = tk.Frame(upper_frame)
right_frame.pack(side="right", fill="both", expand=True)
right_frame.pack_propagate(False)  # 禁用自动调整大小

# 创建操作记录文本框
log_text = ScrolledText(lower_frame, wrap="word", font=("Arial", 12), state=tk.DISABLED)
log_text.pack(fill="both", expand=True)

# 功能按钮
functions_button = tk.Button(left_frame, text="功能", width=10, height=5, command=lambda: show_functions(right_frame, log_operation, log_text))
functions_button.pack(pady=10)

# 设置按钮
settings_button = tk.Button(left_frame, text="设置", width=10, height=5, command=lambda: show_settings(right_frame, log_operation, log_text))
settings_button.pack(pady=10)

# 帮助按钮
help_button = tk.Button(left_frame, text="帮助", width=10, height=5, command=lambda: show_help(right_frame))
help_button.pack(pady=10)

# 打开窗口时默认显示功能页面
show_functions(right_frame, log_operation, log_text)

# 运行主窗口
window.mainloop()
